﻿using System.Windows.Forms;

namespace LANChatClient
{
    public partial class PrivateChat : Form
    {
        /// <summary>
        /// Form class that is used for a private chat window
        /// </summary>
        public PrivateChat()
        {
            InitializeComponent();
            #region load settings
            #region load strings
            LoadStrings();
            #endregion
            #region load theme
            LoadTheme(this,btnSend,txtInputBox,chatTextArea);
            #endregion
            #endregion
        }

        #region load settings functions
        #region load strings function
        /// <summary>
        /// Loads the Private Chat Forms Strings
        /// </summary>
        private void LoadStrings()
        {
            //fail safe, load english strings
            this.Text = ClientPrivateFormStringsEnglish.WindowTitle;
            btnSend.Text = ClientPrivateFormStringsEnglish.SendButton;

            if (Properties.Settings.Default.Language == "de")
            {
                //load german
                this.Text = ClientPrivateFormStringsGerman.WindowTitle;
                btnSend.Text = ClientPrivateFormStringsGerman.SendButton;
            }
            else if (Properties.Settings.Default.Language == "fr")
            {
                //load french
                this.Text = ClientPrivateFormStringsFrench.WindowTitle;
                btnSend.Text = ClientPrivateFormStringsFrench.SendButton;
            }
        }
        #endregion
        #region load theme function
        /// <summary>
        /// Loads the Private Chat Forms Theme
        /// </summary>
        /// <param name="form">Reference to the form</param>
        /// <param name="button">Reference to the button</param>
        /// <param name="inputBox">Reference to the input text box</param>
        /// <param name="chatArea">Reference to the chat rich text box</param>
        private static void LoadTheme(Form form, Button button, TextBox inputBox, RichTextBox chatArea)
        {
            //load default theme as a fail safe
            form.BackColor = System.Drawing.Color.FromName("control");
            form.ForeColor = System.Drawing.Color.FromName("controltext");

            button.BackColor = System.Drawing.Color.FromName("control");
            button.ForeColor = System.Drawing.Color.FromName("controltext");

            inputBox.BackColor = System.Drawing.Color.FromName("Window");
            inputBox.ForeColor = System.Drawing.Color.FromName("WindowText");

            chatArea.BackColor = System.Drawing.Color.FromName("Window");
            chatArea.ForeColor = System.Drawing.Color.FromName("WindowText");

            if (Properties.Settings.Default.Theme == "Classic")
            {
                //overwrite default theme with classic theme if that is set
                form.BackColor = System.Drawing.Color.FromName("black");
                form.ForeColor = System.Drawing.Color.FromName("limegreen");

                button.BackColor = System.Drawing.Color.FromName("black");
                button.ForeColor = System.Drawing.Color.FromName("limegreen");

                inputBox.BackColor = System.Drawing.Color.FromName("black");
                inputBox.ForeColor = System.Drawing.Color.FromName("limegreen");

                chatArea.BackColor = System.Drawing.Color.FromName("black");
                chatArea.ForeColor = System.Drawing.Color.FromName("limegreen");
            }
        }
        #endregion
        #endregion
    }
}
